home *** CD-ROM | disk | FTP | other *** search
-
- /* setxtjfy.c ---settextjustify --- p 855 */
- #include <graphics.h>
- main()
- {
- int graphdriver=DETECT, graphmode;
- int x, y, th, tw;
- initgraph(&graphdriver, &graphmode, "C:\\TURBOC");
- x = getmaxx()/2;
- y = getmaxy()/2;
- /* Mark the point around which text is justified */
- line(x-100, y, x+100, y);
- line(x, y-100, x, y+100);
- /* Try all justification choices */
- settexstyle(TRIPLEX_FONT, HORIZ_DIR, 8);
- tw = textwidth("A");
- th = textheight("A");
- settextjustify(LEFT_TEXT, TOP_TEXT);
- outtextxy(x, y, "A");
- stetextjustify(LEFT_TEXT, BOTTOM_TEXT);
- outtextxy(x, y, "A");
- settextjustify(RIGHT_TEXT, TOP_TEXT);
- outtextxy(x, y, "A");
- settextjustify(RIGHT_TEXT, BOTTOM_TEXT);
- outtextxy(x, y, "A");
- /* Label the choices */
- settextstyle(SMALL_FONT, HORIZ_DIR, 4);
- settextjustify(LEFT_TEXT, BOTTOM_TEXT);
- #define XS (tw+10)
- #define YS (th+10)
- moveto(x+XS, y-YS);
- outtext("LEFT_TEXT, BOTTOM_TEXT");
- moveto(x+XS, y+YS);
- settextjustify(LEFT_TEXT, TOP_TEXT);
- outtext("LEFT_TEXT, TOP_TEXT");
- moveto(x-XS, y+YS);
- settextjustify(RIGHT_TEXT, TOP_TEXT);
- outtext("RIGHT_TEXT, TOP_TEXT");
- settextjustify(RIGHT_TEXT, BOTTOM_TEXT);
- moveto(x-XS, y-YS);
- outtext("RIGHT_TEXT, BOTTOM_TEXT");
- /* Wait until user hits a key */
- getch();
- closegraph();
- }